<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<%

'获取提交查询的参数
tx_search=trim(SafeRequest("tx_search",0))
ksrq=trim(SafeRequest("ksrq",0))
if ksrq<>"" then ksrq=cdate(ksrq)
jsrq=trim(SafeRequest("jsrq",0))
if jsrq<>"" then jsrq=cdate(jsrq)
class_id=trim(SafeRequest("class_id",0))
goods_id=trim(SafeRequest("goods_id",0))
vendor_id=trim(SafeRequest("vendor_id",0))
offer_dept=trim(SafeRequest("offer_dept",0))
offer_empe=trim(SafeRequest("offer_empe",0))
offer_bill=trim(SafeRequest("offer_bill",0))
search_count=trim(SafeRequest("search_count",0))
'组合sql查询字符串
'sql="select * from cdfee where true "
sql="select "
if IsNumeric(search_count) then sql=sql&" top "&search_count
sql=sql&" * from offer_goods where true "
sql_total="select sum(offer_price) as total_offer_price from offer_goods where true "

if tx_search<>"" then sql_where=" and (goods_name like '%"&tx_search&"%' or goods_model like '%"&tx_search&"%' or offer_memo like '%"&tx_search&"%' or vendor_name like '%"&tx_search&"%' or brand_name like '%"&tx_search&"%' or class_name like '%"&tx_search&"%')"
if IsNumeric(class_id) then sql_where=sql_where&" and class_id="&class_id
if IsNumeric(goods_id) then sql_where=sql_where&" and goods_id="&goods_id
if IsNumeric(vendor_id) then sql_where=sql_where&" and vendor_id="&vendor_id
if IsNumeric(offer_dept) then sql_where=sql_where&" and offer_dept="&offer_dept
if IsNumeric(offer_empe) then sql_where=sql_where&" and offer_empe="&offer_empe
if ksrq<>"" and jsrq<>"" then sql_where=sql_where&" and (offer_date>=#"&ksrq&"# and offer_date<=#"&jsrq&"#)"
if offer_bill<>"" then sql_where=sql_where&" and offer_bill="&offer_bill

sql=sql&sql_where
sql_total=sql_total&sql_where

sql_order=" order by offer_update desc"
sql=sql&sql_order
' response.write sql
' response.end
'执行数据查询
set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql_total,conn,1,1
if not rs.eof then total_offer_price=rs("total_offer_price")
rs.close
rs.open sql,conn,1,1
If rs.eof Then
    response.write("没有检索到数据!")
    response.end
End if

'分页控制
If saferequest("page",0)<>"" Then    page=clng(saferequest("page",0)) Else    page=1
pc=saferequest("pc",1)
If pc="" Then pc=25
rs.pagesize=pc
pagesize=rs.pagesize
pagecount=rs.pagecount
'page=clng(request.QueryString("page"))
if Not IsEmpty(page) then '如果page_num已经初始化...
    if Not IsNumeric(page) then '判断page_num值是否为数字
        page=1
    else
        page = clng(page) '接收page_num并化为数字型赋给page_num变量
    end if
    if page > pagecount then '如果接收的页数大于总页数
        rs.AbsolutePage = pagecount '设置当前显示页等于最后页
    elseif page <= 0 then '如果page小于等于0
        page=1
        rs.AbsolutePage = page '设置当前显示页等于第一页
    else
        rs.AbsolutePage = page '如果大于零,显示当前页等于接收的页数
    end if
    page = rs.AbsolutePage
end if

%>



<table class="full">
    <thead>
        <tr>
            <th scope="col"><input type="checkbox" id="checkall"></th>
            <th scope="col">序号</th>
            <th scope="col">领用日期</th>
            <th scope="col">员工</th>
            <th scope="col">部门</th>
            <th scope="col">批号</th>
            <th scope="col">分类</th>
            <th scope="col">文具名</th>
            <th scope="col">品牌</th>
            <th scope="col">型号</th>
            <th scope="col">规格</th>
            <th scope="col">单位</th>
            <th scope="col">数量</th>
            <th scope="col">单价</th>
            <th scope="col">金额</th>
            <th scope="col">经手人</th>
            <th scope="col">结算</th>
            <th scope="col">备注</th>
        </tr>
    </thead>
    <tbody>
<%
    dim sum_offer_price
    sum_offer_price=0
    For i=1 To pagesize
        If rs.eof Then Exit for
%>
        <tr>
            <th class="sub" scope="row"><input type="checkbox" name="checkid" class="checkid" value="<%=rs("offer_id")%>" /></th>
            <td><a href="<%=rs("offer_id")%>"><%=rs.AbsolutePosition%></a></td>
            <td><%=rs("offer_date")%></td>
            <td><%=rs("empe_name")%></td>
            <td><%=rs("dept_name")%></td>
            <td><%=rs("goods_purchase")%></td>
            <td><%=rs("class_name")%></td>
            <td title="<%=rs("goods_memo")%>"><%=rs("goods_name")%></td>
            <td><%=rs("brand_name")%></td>
            <td><%=rs("goods_model")%></td>
            <td><%=rs("goods_spec")%></td>
            <td><%=rs("unit_name")%></td>
            <td><%=rs("offer_quantity")%></td>
            <td><%=rs("goods_unitprice")%></td>
            <td><%=rs("offer_price")%></td>
            <td><%=rs("fullname")%></td>
            <td><%if rs("offer_bill") then response.write "是"%></td>
            <td><%=rs("offer_memo")%></td>
        </tr>
<%
    sum_offer_price=sum_offer_price+rs("offer_price")
    rs.movenext()
next
%>
        <tr>
            <th class="sub" scope="row">合计</th>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td><%=sum_offer_price%></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
<% if page=pagecount then %>        
         <tr>
            <th class="sub" scope="row">总计</th>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td><%=total_offer_price%></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
<% end if %>       
        
    </tbody>
</table>
<div>
    <span>
        <input id="delid" name="delid" type="button" value="删除" />
    </span>
    <span id="pagebar">
        共查询到&nbsp;<%=rs.RecordCount%>&nbsp;条记录&nbsp;
    <%if offer_bill="false" and ksrq<>"" and jsrq<>"" then%>
        <input id="report_search" class="bt_button" type="button" value="生成报表" />&nbsp;&nbsp;
    <%end if%>
        <%    If page>1 Then    %>
            [<a href="#" id="1">首页</a>]
            [<a href="#" id="<%=page-1%>">上一页</a>]
        <%
                End If
                If Not (page>=pagecount Or pagecount=0) Then
        %>
            [<a href="#" id="<%=page+1%>">下一页</a>]
            [<a href="#" id="<%=pagecount%>">尾页</a>]
        <%    End If %>
            第 <%=page%> 页 / 共 <%=pagecount%> 页
            转到<input id="page_val" type="text" size="2" maxlength="<%=Int(Log(pagecount))+1%>" value="<%=page%>" />页
            <input id="page_go" class="bt_button" type="button" value="Go" />
    </span>
</div>
<%
rs.close
Set rs=nothing
%>
<!--#include file="lib/connclose.asp"-->

